/* Copyright 2009
 *
 * This program and the accompanying materials
 * are made available under the terms of the
 * Eclipse Public License v1.0 which accompanies
 * this distribution, and is available at
 *
 * 		http://www.eclipse.org/legal/epl-v10.html
 *
 * Unless required by applicable law or agreed to in
 * writing, software distributed under the License is
 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
 * OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * Contributors:
 * 	   IBM Corporation - initial API and implementation for JDT/DLTK
 *     Sean W. Quinn - initial adoption for use with PHP from various sources.
 */
package org.eclipse.php.internal.ui.preferences.formatter.profile;

import java.util.Map;

import org.eclipse.dltk.ui.formatter.IProfile;

/**
 *
 * @author Sean W. Quinn (swquinn@gmail.com)
 */
public final class SharedProfile extends CustomProfile {
	/** The shared profile identifier. */
	private final static String SHARED_PROFILE = "org.eclipse.jdt.ui.default.shared"; //$NON-NLS-1$

	/**
	 * <p>
	 * Instantiates a new instance of the <code>SharedProfile</code>.
	 * </p>
	 *
	 * @param name the name of this <code>Profile</code>.
	 * @param settings the settings for this <code>Profile</code>.
	 * @param version the current version of this <code>Profile</code>.
	 * @param profileKind the kind of this <code>Profile</code>.
	 */
	public SharedProfile(String oldName, Map settings, int version, String profileKind) {
		super(oldName, settings, version, profileKind);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public PHPProfile rename(String name, PHPProfileManager manager) {
		CustomProfile profile = new CustomProfile(name.trim(), getSettings(), getVersion(), getKind());

		manager.profileReplaced(this, profile);
		return profile;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getID() {
		return SHARED_PROFILE;
	}

	/**
	 */
	@Override
	public final int compareTo(final IProfile profile) {
		return 1;
	}

	/**
	 * @return <tt>false</tt>, <code>SharedProfile</code>s cannot be saved.
	 */
	@Override
	public boolean isProfileToSave() {
		return false;
	}

	/**
	 * @return <tt>true</tt>.
	 */
	@Override
	public boolean isSharedProfile() {
		return true;
	}
}
